﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using YasharEl.Infrastructure.ResourcesManagement;
using System.Globalization;

namespace YasharEl.Infrastructure.TaskEngine
{
    [Serializable]
    public class TaskDefinitionNotFoundException : TranslatedDomainModelException
    {
        private const string TaskDefinitionNotFoundExceptionKey = "TaskDefinitionNotFoundException";

        private readonly long _taskDefinitionId;

        public long RequestedTaskDefinitionId
        {
            get { return _taskDefinitionId; }
        }

        public TaskDefinitionNotFoundException(IResourceManager resourceManager, long taskDefinitionId)
            : base
             (
                resourceManager,
                string.Format(
                    resourceManager.GetString(TaskDefinitionNotFoundExceptionKey, CultureInfo.GetCultureInfo("en")),
                    taskDefinitionId
                )
             )
        {
            _taskDefinitionId = taskDefinitionId;
        }

        protected TaskDefinitionNotFoundException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        protected override string ExceptionMessageResourceKey
        {
            get { return TaskDefinitionNotFoundExceptionKey; }
        }

        public override string TranslatedMessage
        {
            get
            {
                return string.Format(resourceManager.GetString(ExceptionMessageResourceKey), RequestedTaskDefinitionId);
            }
        }
    }
}
